package com.example.service.webhook.business.bank.repository;

import javax.annotation.Resource;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import com.example.service.webhook.business.bank.entity.BankBillDepositEntity;
import com.example.service.webhook.business.bank.entity.BankBillShoppingSheetEntity;
import com.example.service.webhook.repository.base.BaseDAO;
import com.example.service.webhook.util.DateUtil;
import com.example.service.webhook.util.SequenceUtil;
/**
 * 这里用的是jdbctemplate，DAO层可以根据自己的业务来选择
 * ClassName: BillRepository    
 * date: 2016年7月19日 下午6:29:23   
 * @author yuandong  
 * @version   
 * @since JDK 1.6
 */
@Repository
public class BankBillDepositRepository extends BaseDAO<BankBillDepositEntity>{
	
	@Resource(name="templateBank")
    private JdbcTemplate jdbcTemplate;

    public JdbcTemplate getJdbcTemplate() {
		return jdbcTemplate;
	}
    
   
    
    public void saveBankBillDeposit(BankBillDepositEntity entity,String userId) throws Exception  {
    	entity.setCreateTime(DateUtil.getCurrentDate());
    	entity.setLastModifyTime(DateUtil.getCurrentDate());
		this.saveAndReturnKey(entity,getTableName(userId));
    }
    
    public void deleteBankBillDepositByBillId(String cardId,String userId){
    	String sql = "delete from "+getTableName(userId)+" where userId=? and cardId=?";
    	this.delete(sql, new Object[]{userId,cardId});
    }
    
    
    private String getTableName(String userId){
    	return "t_deposit_account";
    }
}
